Repository navigation
Conversation
Use a rough cost model to decide, per recoupling block, between the buffered pack → matmul → unpack path and one direct permuting add per nonzero coefficient of `U`. `buffersize` only accounts for blocks that take the buffered path, and unique fusion gets a separate method. Assisted-by: Claude Code
Codecov Report❌ Patch coverage is
... and 22 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For multi-channel recoupling blocks, index manipulations always went through the buffered pack → matmul → unpack path. This PR decides per block whether to take that path or a direct path (one permuting
tensoradd!per nonzero entry ofU), using a rough cost model inuse_buffered_transform(U, blocksize):nnz(U) * (c₀ + 3 * blocksize)(rows + cols) * c₀ + g + (3 * cols + 4 * rows) * blocksize + rows * cols * blocksize / 4with
c₀ = 30,g = 200.Other changes:
U) has its own method.buffersizeonly counts blocks that take the buffered path, so no buffer is allocated when every block goes direct.Benchmarks (rough)
Whole-tensor
permute!/braid!on an Apple M1, single-threaded (BLAS threads set to 1). The cases cover SU₂ (spin-½ chains with up to 14 legs, 0⊕½⊕1 spaces, degeneracies 2–8) and Fibonacci anyons (6–12 legs), in Float64 and ComplexF64, with cyclic and random permutations: 80 cases in total. Each number is the slowdown relative to the fastest rule on that case:length(U) > 4nnz(U) > rows + colsThe cost model gains most for Fibonacci anyons (up to ~30% over always buffered). It is ~6–14% slower than always buffered for SU₂ spin-½ chains with 12–14 legs.
Help wanted: tuning
The constants were only roughly tuned, and it would be great if someone could take this over:
Uwith tiny blocks.Benchmarking per block is misleading here: the warm, preallocated buffer and cache-resident blocks favour the buffered path. Whole-tensor timings should be used instead.
Assisted by Claude Code